import React from 'react';
import { Layout, Button, Typography } from 'antd';
import {
    FileTextOutlined,
    RobotOutlined,
    ApiOutlined,
    CloudServerOutlined,
    RadarChartOutlined,
    ThunderboltOutlined,
    GlobalOutlined,
    SafetyCertificateOutlined
} from '@ant-design/icons';
import { useNavigate } from 'react-router-dom';
import './index.style.css';

const { Header, Content } = Layout;
const { Title, Paragraph } = Typography;

const HomePage = () => {
    const navigate = useNavigate();

    const handleStartAnalysis = () => {
        // navigate('/text/upload');
        // 检查用户是否已登录
        const userStr = localStorage.getItem('user');
        // if (userStr) {
        //     try {
        //         const user = JSON.parse(userStr);
        //         // 如果有用户信息并且没有过期，直接跳转到上传页面
        //         navigate('/text/upload');
        //     } catch (error) {
        //         // 如果用户信息解析失败，跳转到登录页面
        //         navigate('/login');
        //     }
        // } else {
        //     // 没有用户信息，跳转到登录页面
        //     navigate('/login');
        // }
        navigate('/login');
    };


    return (
        <Layout className="layout">
            <div className="background-decoration">
                <div className="background-grid"></div>
                <div className="background-circles">
                    <div className="background-circle circle-1"></div>
                    <div className="background-circle circle-2"></div>
                </div>
            </div>

            <Header className="header">
                <div className="logo">
                    <RadarChartOutlined className="logo-icon" />
                    <span>文本相似度分析</span>
                </div>
                <div className="header-buttons">
                    {/*<Button type="text">企业空间</Button>*/}
                    {/*<Button type="text">定价</Button>*/}
                    {/*<Button type="text">帮助</Button>*/}
                    <Button type="primary" ghost  onClick={handleStartAnalysis}>登录</Button>
                    <Button type="primary"  onClick={handleStartAnalysis}>加入分析</Button>
                </div>
            </Header>

            <Content className="main-content">
                <div className="left-content">
                    <Title level={1}>智能文本分析</Title>
                    <Title level={2}>精准相似度</Title>
                    <Paragraph className="subtitle">
                        与团队一起分析文本相似度，极致体验，高效协同
                        <br />
                        在协作中构建专业知识库
                    </Paragraph>
                    <Button type="primary" size="large" className="join-button" onClick={handleStartAnalysis}>
                        开始分析
                        <ThunderboltOutlined />
                    </Button>
                </div>
                <div className="right-content">
                    <div className="illustration-container">
                        <div className="feature-icons">
                            <div className="feature-icon icon-1">
                                <RobotOutlined />
                                <span>AI分析</span>
                            </div>
                            <div className="feature-icon icon-2">
                                <GlobalOutlined />
                                <span>多语言支持</span>
                            </div>
                            <div className="feature-icon icon-3">
                                <SafetyCertificateOutlined />
                                <span>安全可靠</span>
                            </div>
                            <div className="feature-icon icon-4">
                                <CloudServerOutlined />
                                <span>云端存储</span>
                            </div>
                        </div>
                        <div className="main-illustration">
                            <FileTextOutlined />
                            <div className="pulse-ring"></div>
                        </div>
                    </div>
                </div>
            </Content>
        </Layout>
    );
};

export default HomePage;
